/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.arecieve.entity;

import javax.validation.constraints.NotBlank;

import com.jeesite.modules.base.entity.customer.Customer;
import com.jeesite.modules.base.entity.supplier.Supplier;
import com.jeesite.modules.base.entity.taccount.Taccount;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import org.hibernate.validator.constraints.Length;
import java.util.Date;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.NotNull;
import java.util.List;
import com.jeesite.common.collect.ListUtils;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

/**
 * 收款单Entity
 * @author wsm
 * @version 2021-03-22
 */
@Table(name="t_receivable", alias="a", columns={
		@Column(name="receivable_id", attrName="receivableId", label="收款单ID", isPK=true),
		@Column(name="receivable_code", attrName="receivableCode", label="编号", queryType=QueryType.LIKE),
		@Column(name="customer_id", attrName="customerId", label="客户"),
		@Column(name="date", attrName="date", label="日期"),
		@Column(name="status1", attrName="status1", label="状态"),
		@Column(name="service_order_id", attrName="serviceOrderId", label="服务订单"),
		//@Column(name="ar_code", attrName="arCode", label="应收单", isQuery=false),
		@Column(name="receivable_amount", attrName="receivableAmount", label="收款/核销金额", isQuery=false),
		@Column(name="currency", attrName="currency", label="币种"),
		@Column(name="receivable_method", attrName="receivableMethod", label="收款方式", isQuery=false),
		@Column(name="receivable_bank", attrName="receivableBank", label="收款银行", isQuery=false),
		@Column(name="advances_received_code", attrName="advancesReceivedCode", label="预收款编号"),
		@Column(name="advances_received_balance", attrName="advancesReceivedBalance", label="预收款余额", isQuery=false),
		@Column(name="create_by", attrName="createBy", label="创建者", isUpdate=false),
		@Column(name="create_date", attrName="createDate", label="创建时间", isUpdate=false),
		@Column(name="update_by", attrName="updateBy", label="更新者", isQuery=false),
		@Column(name="update_date", attrName="updateDate", label="更新时间", isQuery=false),
		@Column(name="remarks", attrName="remarks", label="备注信息", isQuery=false),
	}, joinTable= {
		@JoinTable(type = Type.LEFT_JOIN, entity = Customer.class, attrName = "customer", alias = "b",
				on = "b.customer_id = a.customer_id", columns = {
				@Column(name = "customer_id", label = "供货外商编码", isPK = true),
				@Column(name = "customer_name", label = "供货外商名称", isQuery = false),
		}),
		@JoinTable(type = Type.LEFT_JOIN, entity = ServiceOrder.class, attrName = "serviceOrder", alias = "c",
				on = "c.service_order_id = a.service_order_id", columns = {
				@Column(name = "service_order_id", label = "服务单id", isPK = true),
				@Column(name = "service_order_code", label = "服务单编码", isQuery = false),
		}),
		@JoinTable(type = Type.LEFT_JOIN, entity = Taccount.class, attrName = "taccount", alias = "d",
				on = "d.account_id = a.receivable_bank", columns = {
				@Column(name = "account_id", label = "银行id", isPK = true),
				@Column(name = "account_name", label = "银行名称"),
		})
},orderBy="a.update_date DESC"
)
public class Treceivable extends DataEntity<Treceivable> {

	private static final long serialVersionUID = 1L;
	private String receivableId;		// 收款单ID
	private String receivableCode;		// 编号
	private String customerId;		// 客户
	private Date date;		// 日期
	private String status1;		// 状态
	private String serviceOrderId;		// 服务订单
	private String arCode;		// 应收单
	private Double receivableAmount;		// 收款/核销金额
	private String currency;		// 币种
	private String receivableMethod;		// 收款方式
	private String receivableBank;		// 收款银行
	private String advancesReceivedCode;		// 预收款编号
	private Double advancesReceivedBalance;		// 预收款余额
	private Customer customer;
	private String remarks;
	private List<TreceivableDetail> treceivableDetailList = ListUtils.newArrayList();		// 子表列表
	private String carName;
	private ServiceOrder serviceOrder;
	private Taccount taccount;
	@Override
	public String getRemarks() {
		return remarks;
	}

	@Override
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public Taccount getTaccount() {
		return taccount;
	}

	public void setTaccount(Taccount taccount) {
		this.taccount = taccount;
	}

	public ServiceOrder getServiceOrder() {
		return serviceOrder;
	}

	public void setServiceOrder(ServiceOrder serviceOrder) {
		this.serviceOrder = serviceOrder;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Treceivable() {
		this(null);
	}

	public Treceivable(String id){
		super(id);
	}

	public String getReceivableId() {
		return receivableId;
	}

	public void setReceivableId(String receivableId) {
		this.receivableId = receivableId;
	}


	@Length(min=0, max=100, message="编号长度不能超过 100 个字符")
	public String getReceivableCode() {
		return receivableCode;
	}

	public void setReceivableCode(String receivableCode) {
		this.receivableCode = receivableCode;
	}

	@NotBlank(message="客户不能为空")
	@Length(min=0, max=64, message="客户长度不能超过 64 个字符")
	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}

	@JsonFormat(pattern = "yyyy-MM-dd")
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Length(min=0, max=1, message="状态长度不能超过 1 个字符")
	public String getStatus1() {
		return status1;
	}

	public void setStatus1(String status1) {
		this.status1 = status1;
	}

	@Length(min=0, max=64, message="服务订单长度不能超过 64 个字符")
	public String getServiceOrderId() {
		return serviceOrderId;
	}

	public void setServiceOrderId(String serviceOrderId) {
		this.serviceOrderId = serviceOrderId;
	}

	@Length(min=0, max=100, message="应收单长度不能超过 100 个字符")
	public String getArCode() {
		return arCode;
	}

	public void setArCode(String arCode) {
		this.arCode = arCode;
	}

	public Double getReceivableAmount() {
		return receivableAmount;
	}

	public void setReceivableAmount(Double receivableAmount) {
		this.receivableAmount = receivableAmount;
	}

	@NotBlank(message="币种不能为空")
	@Length(min=0, max=2, message="币种长度不能超过 2 个字符")
	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

	@Length(min=0, max=2, message="收款方式长度不能超过 2 个字符")
	public String getReceivableMethod() {
		return receivableMethod;
	}

	public void setReceivableMethod(String receivableMethod) {
		this.receivableMethod = receivableMethod;
	}

	@Length(min=0, max=50, message="收款银行长度不能超过 50 个字符")
	public String getReceivableBank() {
		return receivableBank;
	}

	public void setReceivableBank(String receivableBank) {
		this.receivableBank = receivableBank;
	}

	@Length(min=0, max=100, message="预收款编号长度不能超过 100 个字符")
	public String getAdvancesReceivedCode() {
		return advancesReceivedCode;
	}

	public void setAdvancesReceivedCode(String advancesReceivedCode) {
		this.advancesReceivedCode = advancesReceivedCode;
	}

	public Double getAdvancesReceivedBalance() {
		return advancesReceivedBalance;
	}

	public void setAdvancesReceivedBalance(Double advancesReceivedBalance) {
		this.advancesReceivedBalance = advancesReceivedBalance;
	}

	public Date getDate_gte() {
		return sqlMap.getWhere().getValue("date", QueryType.GTE);
	}

	public void setDate_gte(Date date) {
		sqlMap.getWhere().and("date", QueryType.GTE, date);
	}

	public Date getDate_lte() {
		return sqlMap.getWhere().getValue("date", QueryType.LTE);
	}

	public void setDate_lte(Date date) {
		sqlMap.getWhere().and("date", QueryType.LTE, date);
	}

	public Date getCreateDate_gte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
	}

	public void setCreateDate_gte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
	}

	public Date getCreateDate_lte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
	}

	public void setCreateDate_lte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
	}

	public List<TreceivableDetail> getTreceivableDetailList() {
		return treceivableDetailList;
	}

	public void setTreceivableDetailList(List<TreceivableDetail> treceivableDetailList) {
		this.treceivableDetailList = treceivableDetailList;
	}

	public String getCarName() {
		return carName;
	}

	public void setCarName(String carName) {
		this.carName = carName;
	}
}
